package com.ogilvy.cms.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ogilvy.cms.bean.CmsPageAudit;
import com.ogilvy.cms.dao.CmsPageAuditDao;
import com.ogilvy.cms.service.CmsPageAuditService;
import com.ogilvy.frame.service.BaseServiceImpl;

@Service
public class CmsPageAuditServiceImpl extends BaseServiceImpl implements CmsPageAuditService {
	@Autowired
	protected CmsPageAuditDao cmsPageAuditDao;
	
	public CmsPageAudit add(CmsPageAudit cmsPageAudit) {
		CmsPageAudit cmspageaudit = cmsPageAuditDao.save(cmsPageAudit);
		return cmspageaudit;
	}

	public boolean del(Integer cpaId) {
		cmsPageAuditDao.deleteById(cpaId);
		return true;
	}

	public boolean modify(CmsPageAudit cmsPageAudit) {
		cmsPageAuditDao.update(cmsPageAudit);
		return true;		
	}
	
	public List<CmsPageAudit> query(CmsPageAudit cmsPageAudit) {
		if(isEmpty(cmsPageAudit.getCpaCmpId())){
			return cmsPageAuditDao.findAll();
		}
		return cmsPageAuditDao.findByProperty("cpaCmpId", cmsPageAudit.getCpaCmpId());
	}
	
	//通过ID进行查询
	public CmsPageAudit get(Integer cpaId){
		return cmsPageAuditDao.get(cpaId);
	}
	
	 /**根据筛选条件查询相关信息*/
	public List<CmsPageAudit> queryByScreen(Map<String, String> screenMap) {
		return cmsPageAuditDao.getListByScreen(screenMap);
	}

	
}
